<!DOCTYPE html>
<html>
<head>
    <title>用户登录</title>
    <!-- Bootstrap -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="__PUBLIC__/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
    <link href="__PUBLIC__/css/styles.css" rel="stylesheet" media="screen">
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script src="__PUBLIC__/js/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body id="login">
<div class="container">
    <form class="form-signin" action="__SELF__" method="post">
        <h2 class="form-signin-heading">请登录</h2>
        <input name="username" type="text" class="input-block-level" placeholder="用户名">
        <input name="password" type="password" class="input-block-level" placeholder="密码">
        <div class="control-group">
            <label class="control-label" for="inputPassword">验证码</label>
            <div class="controls">
                <input type="text" id="inputPassword" class="input-block-level" placeholder="请输入验证码"  errormsg="请填写5位验证码" nullmsg="请填写验证码" datatype="*5-5" name="verify">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label"></label>
            <div class="controls">
                <img class="verifyimg reloadverify" alt="点击切换" src="{:U('verify')}" style="cursor:pointer;">
            </div>
            <div class="controls Validform_checktip text-warning"></div>
        </div>
        <button class="btn btn-large btn-primary" type="submit">登录</button>
        <div class="check-tips"></div>
    </form>
</div> <!-- /container -->
<script src="__PUBLIC__/js/jquery-1.9.1.min.js"></script>
<script src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $("form").submit(function(){
        var self=$(this);
        $.post(self.attr("action"),self.serialize(),success,"json");
        return false;
        function success(data){
            if(data.status){
                window.location.href=data.url;
            }else{
                self.find(".check-tips").text(data.info);
                $('.reloadverify').click();
            }
        }
    });
    $(function(){
        var verifyimg = $(".verifyimg").attr("src");
        $(".reloadverify").click(function(){
            if( verifyimg.indexOf('?')>0){
                $(".verifyimg").attr("src", verifyimg+'&random='+Math.random());
            }else{
                $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
            }
        });
    });
</script>
</body>
</html>